import requests
import os
import json
import random
from dotenv import load_dotenv
from config.aliyun import Aliyun
from prompts.content_page_prompt import get_content_prompt
from prompts.teching_script_prompt import get_teching_prompt
def generate_with_aliyun(prompt):
    """使用阿里云API生成内容"""
    aliyun=Aliyun()
    response=aliyun.generate(prompt)
    if not response:
        raise ValueError("阿里云接口返回空数据")
    try:
        return response
    except:
        return {"error": "invalid response"}

def generate_prompt(keyword,template):
    if template=="content":
        return get_content_prompt(keyword)
    elif template=="script":
        return get_teching_prompt(keyword)